package com.daima;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.Collections;

/**
 * @author: LCG
 * @Date: 2021-11-01 11:40:34
 * @description:
 **/
@SpringBootApplication
public class TestMyBatisPlus {
    public static void main(String[] args) {
        //SpringApplication.run(TestMyBatisPlus.class,args);
        genDaima();
    }


    public static void genDaima(){
        FastAutoGenerator.create("jdbc:mysql://39.96.50.149:3306/oms?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&useSSL=true", "root", "zHqpU9wJpR6AjIr6dwiw")
                .globalConfig(builder -> {
                    builder.author("lcg") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("D://DAI-MA"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("cn.xingqutuan.oms") // 设置父包名
                            .moduleName("XXX") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D://DAI-MA")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("saas_store_app_version_info") // 设置需要生成的表名
                            .addTablePrefix("t_", "c_")
                    .entityBuilder()
                    .enableTableFieldAnnotation()
                    .enableLombok()
                    .serviceBuilder()
                    .mapperBuilder()
                    .enableBaseResultMap()
                    .enableMapperAnnotation()
                    .superClass(BaseMapper.class)
                    ; // 设置过滤表前缀
                })



                // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
